<?php
class NotificationDAO extends DataLayer {	
	/**
	* @desc Construtor da Classe
 	*/
	function __construct($lk){
		$this->lk = $lk;	
	}

	public function saveChangeTaskState(Task $objTask, $idSprint, $idUser, $idProject){

		$objTaskDAO		= new TaskDAO($this->lk);
		$objTaskState	= $objTaskDAO->getTasksStates($objTask->idTaskState, $idProject);
		$objTask		= $objTaskDAO->getTasks($objTask->id, $idProject);
		
		$objSprintDAO	= new SprintDAO($this->lk);
		$objSprint		= $objSprintDAO->getSprints($idSprint, $idProject);
		
		$objUserTeamDAO	= new UserTeamDAO($this->lk);
		$objUserTeam	= $objUserTeamDAO->getUsersTeam(0,$objSprint[0]->idTeam);

		$mensage = 'A Tarefa "'.$objTask[0]->name.'" foi alterada para o estado "'.$objTaskState[0]->name.'".';
		
		$dbObj["descricao"]	= $mensage;

		foreach($objUserTeam as $row){
			if($row->idUser == $idUser)
				continue;

			$dbObj["id_usuario"]= $row->idUser;	
			parent::insert("notificacoes",$dbObj,"data");			
		}
		
	}
}